package com.lej.dataservice.club.bean.privilege

import android.text.SpannableStringBuilder
import com.lej.core.dsl.sp
import com.lej.core.utils.changeFormatMoney
import com.lej.core.utils.extention.setFontSize
import com.lej.dataservice.club.http.BaseListBean

/**
|参数名|类型|说明|
|reward_id |:——-|领取动作时时参数 |
|status |:——-|0已经领取，1待领取，2去完成 |
|h5 |:——-| 状态为2去完成 且不为空时 跳转地址 |
|app_jump |:——-| 优先级低于h5, app内部跳转标识 |

app_jump
===================1.0.8 版本 跳转码=======================
参与聊天 -》暂进社区-》1301
发布社区动态-》进社区-》1301
每日打卡视频、每日打卡照片-》暂进app首页-》1300
完善个人信息-》暂进个人设置页-》1318
学校认证-》1312
上传头像-》暂进个人设置页-》1318
真人认证-》特权页只要能进入总是完成状态*/
data class TaskBean(
    val app_jump: String,
    val event_id: String,
    val h5: String,
    val reward_id: String,
    val gold: Int,
    val award_score: String?,//积分奖励 （现金 实物 积分三者组合展示）
    val in_kind: String?,//实物奖励或者自定义奖励文案（现金 实物 积分三者组合展示）

    //积分任务:0已经领取，1待领取，2去完成
    //现金任务:0可领取，1拒绝 2进行中 3待审核 4用户放弃 9完成
    var status: String,
    ///按钮文字
    val status_desc: String,
    var bg_image: String,
    val title: String,
    val tips: String,//新增】右上角角标文字
    val brand: String,//品牌
    val goods: String,//产品名
    val follower_limit: String,//【新增】要求粉丝数
    val expired_at: String,//截止时间

    val task_tags: List<TaskTag>?,
    val apply_button_content: String?,//报名按钮自定义文字内容
    val disable: Int,//置灰任务 0正常1置灰

    val task_level: Int,//【培训版本新增】右上角任务等级
) {

    fun couponsStr() = "+${gold}积分"

    //是否需要置灰
    fun isDisable() = disable == 1

    fun getCustomGold() = when {
        !in_kind.isNullOrEmpty() -> in_kind.setFontSize(15.sp)
        gold > 0 -> SpannableStringBuilder("¥ ".setFontSize(11.sp))
            .append(gold.changeFormatMoney().setFontSize(20.sp))
        !award_score.isNullOrEmpty() -> SpannableStringBuilder(award_score.setFontSize(20.sp))
            .append(" 积分".setFontSize(11.sp))
        else -> ""
    }

    override fun hashCode(): Int {
        var result = app_jump.hashCode()
        result = 31 * result + event_id.hashCode()
        result = 31 * result + h5.hashCode()
        result = 31 * result + reward_id.hashCode()
        result = 31 * result + gold
        result = 31 * result + status.hashCode()
        result = 31 * result + status_desc.hashCode()
        result = 31 * result + bg_image.hashCode()
        result = 31 * result + title.hashCode()
        result = 31 * result + tips.hashCode()
        result = 31 * result + brand.hashCode()
        result = 31 * result + goods.hashCode()
        result = 31 * result + follower_limit.hashCode()
        result = 31 * result + expired_at.hashCode()
        result = 31 * result + (task_tags?.hashCode() ?: 0)
        result = 31 * result + apply_button_content.hashCode()
        return result
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false
        other as TaskBean
        if (app_jump != other.app_jump) return false
        if (event_id != other.event_id) return false
        if (h5 != other.h5) return false
        if (reward_id != other.reward_id) return false
        if (gold != other.gold) return false
        if (status != other.status) return false
        if (status_desc != other.status_desc) return false
        if (bg_image != other.bg_image) return false
        if (title != other.title) return false
        if (tips != other.tips) return false
        if (brand != other.brand) return false
        if (goods != other.goods) return false
        if (follower_limit != other.follower_limit) return false
        if (expired_at != other.expired_at) return false
        if (task_tags != other.task_tags) return false
        if (apply_button_content != other.apply_button_content) return false
        return true
    }
}


data class TaskTag(
    var tag_name: String,//标签名
    /**任务标签颜色1绿2红*/
    var cate: Int
)

data class TaskRes(
    //0当前不需要提示真人验证，1当前需要提示真人验证
    var base_photo_needed: Int,
    var banner_betanumber: BannerTop?,
    var banner_list: List<BannerTop>?,
    var gold_total: Int,//总积分
    var user_task_level: Int,//任务等级 用户当前等级0未知&100初级200中级300高级
    var bill_total: Int,//总现金
) : BaseListBean<TaskBean>() {
    fun hasFaceSign() = base_photo_needed == 1
}

data class BannerTop(var banner_image: String?, var banner_href: String?, var app_jump: Int)

data class RewardRes(var title: String)